package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCFaultLevel;
import com.shrct.businessprocess.customerservice.RCFaultReport;
import com.shrct.businessprocess.customerservice.RCFaultReportCriteria;
import com.shrct.businessprocess.customerservice.RCFaultStatus;
import com.shrct.businessprocess.customerservice.RCTimeLevel;
import com.shrct.businessprocess.organization.RCEnterprise;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import java.util.Date;
import org.hibernate.Query;

public class RCFaultReportCriteriaImpl extends HQLBasedPagedQueryCriteria<RCFaultReport> implements RCFaultReportCriteria {
  private String sid;
  
  public String getSid() {
    return this.sid;
  }
  
  public RCFaultReportCriteria setSid(final String sid) {
    this.sid = sid;
    return this;			
    
  }
  
  private Date reportDateFrom;
  
  public Date getReportDateFrom() {
    return this.reportDateFrom;
  }
  
  public RCFaultReportCriteria setReportDateFrom(final Date reportDateFrom) {
    this.reportDateFrom = reportDateFrom;
    return this;			
    
  }
  
  private Date reportDateTo;
  
  public Date getReportDateTo() {
    return this.reportDateTo;
  }
  
  public RCFaultReportCriteria setReportDateTo(final Date reportDateTo) {
    this.reportDateTo = reportDateTo;
    return this;			
    
  }
  
  private RCFaultLevel faultLevel;
  
  public RCFaultLevel getFaultLevel() {
    return this.faultLevel;
  }
  
  public RCFaultReportCriteria setFaultLevel(final RCFaultLevel faultLevel) {
    this.faultLevel = faultLevel;
    return this;			
    
  }
  
  private RCTimeLevel timeLevel;
  
  public RCTimeLevel getTimeLevel() {
    return this.timeLevel;
  }
  
  public RCFaultReportCriteria setTimeLevel(final RCTimeLevel timeLevel) {
    this.timeLevel = timeLevel;
    return this;			
    
  }
  
  private RCFaultStatus status;
  
  public RCFaultStatus getStatus() {
    return this.status;
  }
  
  public RCFaultReportCriteria setStatus(final RCFaultStatus status) {
    this.status = status;
    return this;			
    
  }
  
  private RCEnterprise customer;
  
  public RCEnterprise getCustomer() {
    return this.customer;
  }
  
  public RCFaultReportCriteria setCustomer(final RCEnterprise customer) {
    this.customer = customer;
    return this;			
    
  }
  
  private Boolean marked;
  
  public Boolean getMarked() {
    return this.marked;
  }
  
  public RCFaultReportCriteria setMarked(final Boolean marked) {
    this.marked = marked;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.customerservice.impl.RCFaultReportImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSid()) ){
    	hql += " and (this.sid  LIKE :sid)" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getReportDateFrom()) ){
    	hql += " and ((this.reportDate) >= (:reportDateFrom))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getReportDateTo()) ){
    	hql += " and ((this.reportDate) <= (:reportDateTo))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getFaultLevel()) ){
    	hql += " and ((this.faultLevel) = (:faultLevel))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getTimeLevel()) ){
    	hql += " and ((this.timeLevel) = (:timeLevel))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus()) ){
    	hql += " and ((this.status) = (:status))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCustomer()) ){
    	hql += " and ((this.customer) = (:customer))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getMarked()) ){
    	hql += " and ((this.marked) = (:marked))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    addOrder("this.reportDate",edu.fudan.mylang.pf.query.OrderItem.DESC);
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSid())){
    	query.setParameter("sid",getSid()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getReportDateFrom())){
    	query.setParameter("reportDateFrom",getReportDateFrom()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getReportDateTo())){
    	query.setParameter("reportDateTo",getReportDateTo()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getFaultLevel())){
    	query.setParameter("faultLevel",getFaultLevel()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getTimeLevel())){
    	query.setParameter("timeLevel",getTimeLevel()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus())){
    	query.setParameter("status",getStatus()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCustomer())){
    	query.setParameter("customer",getCustomer()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getMarked())){
    	query.setParameter("marked",getMarked()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RCFaultReportCriteriaImpl() {
    initOrderBys();
  }
}
